<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>客户列表</title>
    <#include "../common/link.ftl"/>
    <script>
        $(function () {
            //回显数据
            $(".btn-input").click(function () {
                var json = $(this).data("json");
                console.log(json);
                if (json) {
                    $("input[name='id']").val(json.id);
                    $("input[name='name']").val(json.name);
                    $("input[name='sn']").val(json.sn);
                } else {
                    $("input").val("");
                }
                $('#myModal').modal('show');
            })

            //提交表单
            $(".btn-submit").click(function () {
                $.messager.confirm("温馨提示", "确认保存吗", function () {
                    $("#editForm").ajaxSubmit(function (data) {
                        if (data.success){
                            $.messager.popup("保存成功,两秒后跳转页面")
                            setTimeout(function () {
                                window.location.reload();
                            },2000)
                        }else{
                            $.messager.popup(data.msg);
                        }
                    })
                })
            })
            //删除操作
            $(".btn-delete").click(function () {
                var url = $(this).data("url");
                $.messager.confirm("温馨提示","确定要删除吗",function () {
                    $.get(url,function (data) {
                        if(data.success){
                            $.messager.popup("删除成功,2秒后跳转页面");
                            setTimeout(function () {
                                window.location.reload();
                            },2000)
                        }else{
                            $.messager.popup(data.msg);
                        }
                    })
                })
            })

        })
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#include "../common/navbar.ftl" />
    <!--菜单回显-->
<#assign currentMenu="customer"/>
<#include "../common/menu.ftl" />
    <div class="content-wrapper">
        <section class="content-header">
            <h1>客户列表管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <!--高级查询--->
                    <form class="form-inline" id="searchForm" action="/customer/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyword">关键字:</label>
                            <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入姓名/电话">
                        </div>
                        <div class="form-group">
                            <label for="status">状态:</label>
                            <select class="form-control" id="status" name="status">
                                <option value="-1">全部</option>
                                <option value="0">潜在客户</option>
                                <option value="1">正式客户</option>
                                <option value="2">资源池客户</option>
                                <option value="3">失败客户</option>
                                <option value="4">流失客户</option>
                            </select>
                            <script>
                                $("#status option[value='${(qo.status)!}']").prop("selected", true);
                            </script>
                        </div>

                        <div class="form-group">
                            <label for="seller">市场专员:</label>
                            <select class="form-control" id="seller" name="sellerId">
                                <option value="-1">全部</option>
                                <#list sellers as seller>
                                    <option value="${seller.id}">${seller.name}</option>
                                </#list>
                            </select>
                            <script>
                                $("#seller option[value='${qo.sellerId}']").prop("selected", true);
                            </script>
                        </div>
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                    </form>
                </div>

                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered" align="center">
                        <tr>
                            <th>编号</th>
                            <th>名称</th>
                            <th>性别</th>
                            <th>年龄</th>
                            <th>电话</th>
                            <th>QQ</th>
                            <th>职业</th>
                            <th>来源</th>
                            <th>市场专员</th>
                            <th>状态</th>
                        </tr>

                        <#list pageInfo.list as entry>
                            <tr>
                                <td>${entry_index+1}</td>
                                <td>${entry.name}</td>
                                <td>${entry.genderName}</td>
                                <td>${entry.age}</td>
                                <td>${entry.tel}</td>
                                <td>${entry.qq}</td>
                                <td>${entry.job.title}</td>
                                <td>${entry.source.title}</td>
                                <td>${entry.seller.name}</td>
                                <td>${entry.statusName}</td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl"/>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl" />
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">部门管理</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/entry/saveOrUpdate" method="post" id="editForm">
                    <input type="hidden" name="id">

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-2 control-label">名称：</label>
                        <div class="col-sm-4">
                            <input type="text" name="name" class="form-control" id="name" style="width: 366px"
                                   placeholder="请输入部门名">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">编码：</label>
                        <div class="col-sm-4">
                            <input type="text" name="sn" class="form-control" id="sn" style="width: 366px"
                                   placeholder="请输入部门编码">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>


</body>
</html>
